home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (PO) / Nibble Volume 10, No. 08 (1989-08)(MindCraft Publishing)(Side A).zip / Nibble Volume 10, No. 08 (1989-08)(MindCraft Publishing)(Side A).po / CLEAN.S < prev    next >
Text File  |  1996-12-24  |  4KB  |  118 lines

  1. ******************************
  2. * CLEAN Source Code
  3. * By Jim Richardson
  4. * Copyright(c) 1989
  5. * MindCraft Publ. Corp.
  6. * Concord, Ma 01742
  7. * EDITOR ASSEMBLER
  8. ******************************
  9. * Syntax: CLEAN [,Dn][,Sn]
  10. * Installs external command "CLEAN"  
  11. * which will turn on the default or
  12. * indicated drive for 30 seconds.
  13. * If the diskette is a standard formatted
  14. * disk, control will return immediately to
  15. * BASIC.SYSTEM with no error indicated.
  16. *-----------------
  17. * EQUATES
  18. *-----------------
  19. INBUF     EQU $200       ;Input buffer
  20. EXTRNCMD  EQU $BE06      ;External command vector
  21. XTRNADDR  EQU $BE50      ;External command execution
  22. XLEN      EQU $BE52      ;Command length minus one
  23. XCNUM     EQU $BE53      ;Command number (ext cmd=0)
  24. PBITS     EQU $BE54      ;Permitted parameter bits
  25. VSLOT     EQU $BE61      ;Default slot for active volume
  26. VDRIV     EQU $BE62      ;Default drive number for active volume
  27. MLI       EQU $BF00      ;Machine Language Interface
  28. *
  29.           ORG $300
  30. *
  31. SETUP     LDA EXTRNCMD+1
  32.           STA NXTCMD+1
  33.           LDA EXTRNCMD+2 ;Move current EXTRNCMD vector to
  34.           STA NXTCMD+2   ;our next external command vector
  35.           LDA #<ENTRY
  36.           STA EXTRNCMD+2
  37.           LDA #>ENTRY    ;Change EXTRNCMD vctr to point to
  38.           STA EXTRNCMD+1 ;beginning of our code.
  39.           CLC
  40.           RTS            ;Return with no error
  41. *
  42. ENTRY     CLD            ;Required by BI
  43.           LDX #0
  44.           LDY #0
  45. PARSE     JSR GBUFCHAR   ;Get char from INBUF
  46.           EOR TXCLEAN,Y  ;Compare it to 'CLEAN'
  47.           BNE NXTCMD     ;=> Command not found
  48.           INY            ;Try next char
  49.           CPY #5  
  50.           BCC PARSE      ;compare all five char's in name
  51.           DEY
  52.           STY XLEN       ;Found! Save length(-1) of cmnd string
  53.           LDA #0
  54.           STA XCNUM      ;Indicate that this is an External cmnd
  55.           LDA #$11
  56.           STA PBITS      ;Filename expected but optional
  57. *   (S & D parameters didn't seem to work without Pathname allowed)
  58.           LDA #4
  59.           STA PBITS+1    ;Allow S,D parameters
  60.           LDY #>RTNADR
  61.           LDA #<RTNADR   ;Return addr in A Y
  62.           STY XTRNADDR
  63.           STA XTRNADDR+1 ;Tell BI where to return
  64.           CLC            ;No errors - command found
  65.           RTS            ;Back to BI for more parsing
  66. RTNADR    LDA VSLOT      ;Get slot number
  67.           ASL
  68.           ASL
  69.           ASL
  70.           ASL            ;Slot num moved to hi nibble
  71.           STA UNITNUM    ;Save $0SSS0000
  72.           LDA VDRIV      ;Get drive number
  73.           LSR            ;Make 2=1 or 1=0
  74.           LSR            ;move 1 or 0 to carry
  75.           ROR            ;move 1 or 0 to high bit (bit 7)
  76.           ADC UNITNUM    ;Add drive num to slot num
  77.           STA UNITNUM    ;save $DSSS0000
  78.           LDA #$00
  79. * Reads block $00,$20,$40,$60,$80,$A0,$C0,$E0
  80. * Takes aprox. 30 seconds required to clean heads.
  81. TRAC      STA BLOCKNUM   ;Move arm over two tracks (or init to $00)
  82.           JSR MLI        ;READ.BLOCK (engage head to cleaning disk)
  83.           DFB $80
  84.           DW RPARM       ;We expect error if reading cleaning disk
  85.           BCC EXIT       ;=>Exit if reading a "real" disk
  86.           CLC
  87.           LDA BLOCKNUM   ;BLOCKNUM used to keep track of time
  88.           ADC #$20
  89.           BCC TRAC       ;=> if block # < $FF
  90.           CLC            ;time up
  91. EXIT      RTS            ;Return to BI
  92. *----------------------
  93. * Subroutine
  94. *----------------------
  95. * Flush non-space character from INBUF:
  96. * Written by Sandy Mossberg
  97. *
  98. GBUFCHAR  LDA INBUF,X
  99.           INX
  100.           CMP #' '
  101.           BEQ GBUFCHAR
  102.           CMP #'a'
  103.           BCC ISUPPER
  104.           AND #$DF       ;Ensure upper case
  105. ISUPPER   CMP #$8D
  106.           RTS            ;EQ=CR; NE=other char
  107. *
  108. NXTCMD    JMP $0000      ;Chain to next external command
  109.           MSB ON
  110. TXCLEAN   ASC 'CLEAN'
  111. *------------------
  112. * READ BLOCK PARAMETERS
  113. *------------------
  114. RPARM     DFB $03
  115. UNITNUM   DS 1
  116. DATA      DW $2000
  117. BLOCKNUM  DW $0000
  118.